package org.dromara.yuanshidian.controller;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.yuanshidian.domain.vo.Ab04NewVo;
import org.dromara.yuanshidian.domain.bo.Ab04NewBo;
import org.dromara.yuanshidian.service.IAb04NewService;
import org.dromara.common.mybatis.core.page.TableDataInfo;

/**
 * 新人员账户明细(缴费明细)
 *
 * @author TzhongTop
 * @date 2025-01-24
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/yuanshidian/ab04new")
public class Ab04NewController extends BaseController {

    private final IAb04NewService ab04NewService;

    /**
     * 查询新人员账户明细(缴费明细)列表
     */
    //@SaCheckPermission("yuanshidian:ab04new:list")
    @GetMapping("/list")
    public TableDataInfo<Ab04NewVo> list(Ab04NewBo bo, PageQuery pageQuery) {
        return ab04NewService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出新人员账户明细(缴费明细)列表
     */
    //@SaCheckPermission("yuanshidian:ab04new:export")
    @Log(title = "新人员账户明细(缴费明细)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(Ab04NewBo bo, HttpServletResponse response) {
        List<Ab04NewVo> list = ab04NewService.queryList(bo);
        ExcelUtil.exportExcel(list, "新人员账户明细(缴费明细)", Ab04NewVo.class, response);
    }

    /**
     * 获取新人员账户明细(缴费明细)详细信息
     *
     * @param ID 主键
     */
    //@SaCheckPermission("yuanshidian:ab04new:query")
    @GetMapping("/{ID}")
    public R<Ab04NewVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long ID) {
        return R.ok(ab04NewService.queryById(ID));
    }

    /**
     * 新增新人员账户明细(缴费明细)
     */
    //@SaCheckPermission("yuanshidian:ab04new:add")
    @Log(title = "新人员账户明细(缴费明细)", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody Ab04NewBo bo) {
        return toAjax(ab04NewService.insertByBo(bo));
    }

    /**
     * 修改新人员账户明细(缴费明细)
     */
    //@SaCheckPermission("yuanshidian:ab04new:edit")
    @Log(title = "新人员账户明细(缴费明细)", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody Ab04NewBo bo) {
        return toAjax(ab04NewService.updateByBo(bo));
    }

    /**
     * 删除新人员账户明细(缴费明细)
     *
     * @param IDs 主键串
     */
    //@SaCheckPermission("yuanshidian:ab04new:remove")
    @Log(title = "新人员账户明细(缴费明细)", businessType = BusinessType.DELETE)
    @DeleteMapping("/{IDs}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] IDs) {
        return toAjax(ab04NewService.deleteWithValidByIds(List.of(IDs), true));
    }
}
